package com.example.yls.demoa;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button btn_clear;
    private MySurfaceView mySurfaceView;

    private Button btn_red;
    private Button btn_blue;
    private Button btn_green;
    private Button btn_yellow;
    private Button btn_addPenSize;
    private Button btn_Circle;
    private Button btn_Rect;
    private MyView myView;
    private int size = 5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btn_blue = findViewById(R.id.btn_blue);
        btn_red = findViewById(R.id.btn_red);
        btn_green = findViewById(R.id.btn_green);
        btn_yellow = findViewById(R.id.btn_yellow);
        btn_addPenSize = findViewById(R.id.btn_addPenSie);
        btn_Circle = findViewById(R.id.btn_Clrice);
        btn_Rect = findViewById(R.id.btn_Rrect);

        btn_Rect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                myView.setPaintMode(MyView.RECT);


            }
        });

        btn_Circle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                myView.setPaintMode(MyView.CIRCLE);
            }
        });

        btn_addPenSize.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                myView.addPenSize(size);
                size += 1;
            }
        });

        btn_yellow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                myView.setBackgroundColor(Color.YELLOW);
            }
        });


        btn_green.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                myView.setBackgroundColor(Color.GREEN);
            }
        });
        myView = findViewById(R.id.myView);

        btn_blue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                myView.setPaintColor(Color.BLUE);

            }
        });

        btn_red.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                myView.setPaintColor(Color.RED);

            }
        });
//        btn_clear = findViewById(R.id.btn_clear);
//        mySurfaceView = findViewById(R.id.mySurFaceView);
//        btn_clear.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                mySurfaceView.reset();
//
//            }
//        });
    }
}
